from django.db import models


class Department(models.Model):
    """部门表"""
    title = models.CharField(max_length=100,verbose_name='部门名称',unique=True)


    def __str__(self):
        return self.title

# 员工表
class Employee(models.Model):
    """员工表"""
    name = models.CharField(max_length=100,verbose_name='员工姓名')
    gender_choice = (
        (1,'男'),
        (2,'女'),
    )
    gender = models.IntegerField(choices=gender_choice,verbose_name='性别')
    age = models.IntegerField(verbose_name='年龄')
    salary = models.DecimalField(verbose_name='工资',default=0, max_digits=10,decimal_places=2)
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='入职时间')
    depart = models.ForeignKey(Department,null=True,on_delete=models.SET_NULL,verbose_name='部门')

    def __str__(self):
        return self.name